package com.example.controller;

import com.example.entity.Comment;
import com.example.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CommentController {
    @Autowired
    private CommentService commentService;

    @GetMapping("/get/{id}")
    public Comment findComment(@PathVariable("id") Integer id){
        return commentService.findById(id);
    }

    @GetMapping("/update/{id}/{content}")
    public Comment updateComment(@PathVariable("id") Integer id, @PathVariable("content") String content){
        return commentService.UpdateComment(id, content);
    }

    @GetMapping("/delete/{id}")
    public void deleteComment(@PathVariable("id") Integer id){
        commentService.deleteComment(id);
    }

}
